package com.chenxinzhi.codetools.message

import com.intellij.DynamicBundle
import org.jetbrains.annotations.Nls
import org.jetbrains.annotations.NonNls
import org.jetbrains.annotations.PropertyKey
import java.util.function.Supplier

object Messages {
    @NonNls
    private const val BUNDLE = "messages.MessagesBundle"
    private val INSTANCE = DynamicBundle(Messages::class.java, BUNDLE)
    fun message(
        key: @PropertyKey(resourceBundle = BUNDLE) String,
        vararg params: Any
    ): @Nls String {
        return INSTANCE.getMessage(key, *params)
    }

    fun lazyMessage(
        @PropertyKey(resourceBundle = BUNDLE) key: String,
        vararg params: Any
    ): Supplier<@Nls String> {
        return INSTANCE.getLazyMessage(key, *params)
    }
}

fun message(
    key: String,
    vararg params: Any
): String {
    return Messages.message(key, *params)
}

fun lazyMessage(
    key: String,
    vararg params: Any
): Supplier<String> {
    return Messages.lazyMessage(key, *params)
}

